void reverseLinkedList(struct ListNode *head){
    struct ListNode *pre=NULL;
    struct ListNode *cur=head;

    while (cur!=NULL) {
        struct ListNode *next=cur->next;
        cur->next=pre;
        pre=cur;
        cur=next;
    }
}
struct ListNode *reverseBetween(struct ListNode *head, int left, int right) {
    struct ListNode *dummyNode = malloc(sizeof(struct ListNode));
    dummyNode->val=-1;
    dummyNode->next=head;

    struct ListNode *pre=dummyNode;
    for (int y=0;y<left-1;y++){
        pre=pre->next;
    }
    struct ListNode *rightNode=pre;
    for (int y=0;y<right-left+1;y++){
        rightNode=rightNode->next;
    }
    struct ListNode *leftNode=pre->next;
    struct ListNode *curr=rightNode->next;

    pre->next=NULL;
    rightNode->next=NULL;

    reverseLinkedList(leftNode);

    pre->next=rightNode;
    leftNode->next=curr;
    return dummyNode->next;
} 